﻿Imports System
Imports System.Workflow.ComponentModel
Imports System.Workflow.ComponentModel.Compiler

Namespace System.Workflow.Activities
    Friend NotInheritable Class ConditionedActivityGroupValidator
        Inherits CompositeActivityValidator
        ' Methods
        Public Overrides Function Validate(ByVal manager As ValidationManager, ByVal obj As Object) As ValidationErrorCollection
            Dim errors As ValidationErrorCollection = MyBase.Validate(manager, obj)
            If Not TypeOf obj Is ConditionedActivityGroup Then
                Throw New ArgumentException(SR.GetString("Error_UnexpectedArgumentType", New Object() { GetType(ConditionedActivityGroup).FullName }), "obj")
            End If
            Return errors
        End Function

        Public Overrides Function ValidateActivityChange(ByVal activity As Activity, ByVal action As ActivityChangeAction) As ValidationError
            If (activity Is Nothing) Then
                Throw New ArgumentNullException("activity")
            End If
            If (action Is Nothing) Then
                Throw New ArgumentNullException("action")
            End If
            If (((activity.ExecutionStatus <> ActivityExecutionStatus.Initialized) AndAlso (activity.ExecutionStatus <> ActivityExecutionStatus.Executing)) AndAlso (activity.ExecutionStatus <> ActivityExecutionStatus.Closed)) Then
                Return New ValidationError(SR.GetString("Error_DynamicActivity2", New Object() { activity.QualifiedName, activity.ExecutionStatus, activity.GetType.FullName }), &H50F)
            End If
            Return Nothing
        End Function

    End Class
End Namespace

